home *** CD-ROM | disk | FTP | other *** search
- '\"
- '\" Copyright (c) 1993 The Regents of the University of California.
- '\" All rights reserved.
- '\"
- '\" Permission is hereby granted, without written agreement and without
- '\" license or royalty fees, to use, copy, modify, and distribute this
- '\" documentation for any purpose, provided that the above copyright
- '\" notice and the following two paragraphs appear in all copies.
- '\"
- '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
- '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
- '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- '\"
- '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- '\" AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
- '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- '\"
- '\" $Header: /user6/ouster/tcl/man/RCS/string.n,v 1.1 93/06/16 16:48:24 ouster Exp $ SPRITE (Berkeley)
- '\"
- .\" The definitions below are for supplemental macros used in Tcl/Tk
- .\" manual entries.
- .\"
- .\" .HS name section [date [version]]
- .\" Replacement for .TH in other man pages. See below for valid
- .\" section names.
- .\"
- .\" .AP type name in/out [indent]
- .\" Start paragraph describing an argument to a library procedure.
- .\" type is type of argument (int, etc.), in/out is either "in", "out",
- .\" or "in/out" to describe whether procedure reads or modifies arg,
- .\" and indent is equivalent to second arg of .IP (shouldn't ever be
- .\" needed; use .AS below instead)
- .\"
- .\" .AS [type [name]]
- .\" Give maximum sizes of arguments for setting tab stops. Type and
- .\" name are examples of largest possible arguments that will be passed
- .\" to .AP later. If args are omitted, default tab stops are used.
- .\"
- .\" .BS
- .\" Start box enclosure. From here until next .BE, everything will be
- .\" enclosed in one large box.
- .\"
- .\" .BE
- .\" End of box enclosure.
- .\"
- .\" .VS
- .\" Begin vertical sidebar, for use in marking newly-changed parts
- .\" of man pages.
- .\"
- .\" .VE
- .\" End of vertical sidebar.
- .\"
- .\" .DS
- .\" Begin an indented unfilled display.
- .\"
- .\" .DE
- .\" End of indented unfilled display.
- .\"
- '\" # Heading for Tcl/Tk man pages
- .de HS
- .ds ^3 \\0
- .if !"\\$3"" .ds ^3 \\$3
- .if '\\$2'cmds' .TH \\$1 1 \\*(^3 \\$4
- .if '\\$2'lib' .TH \\$1 3 \\*(^3 \\$4
- .if '\\$2'tcl' .TH \\$1 n \\*(^3 Tcl "Tcl Built-In Commands"
- .if '\\$2'tk' .TH \\$1 n \\*(^3 Tk "Tk Commands"
- .if '\\$2'tclc' .TH \\$1 3 \\*(^3 Tcl "Tcl Library Procedures"
- .if '\\$2'tkc' .TH \\$1 3 \\*(^3 Tk "Tk Library Procedures"
- .if '\\$2'tclcmds' .TH \\$1 1 \\*(^3 Tk "Tcl Applications"
- .if '\\$2'tkcmds' .TH \\$1 1 \\*(^3 Tk "Tk Applications"
- .if t .wh -1.3i ^B
- .nr ^l \\n(.l
- .ad b
- ..
- '\" # Start an argument description
- .de AP
- .ie !"\\$4"" .TP \\$4
- .el \{\
- . ie !"\\$2"" .TP \\n()Cu
- . el .TP 15
- .\}
- .ie !"\\$3"" \{\
- .ta \\n()Au \\n()Bu
- \&\\$1 \\fI\\$2\\fP (\\$3)
- .\".b
- .\}
- .el \{\
- .br
- .ie !"\\$2"" \{\
- \&\\$1 \\fI\\$2\\fP
- .\}
- .el \{\
- \&\\fI\\$1\\fP
- .\}
- .\}
- ..
- '\" # define tabbing values for .AP
- .de AS
- .nr )A 10n
- .if !"\\$1"" .nr )A \\w'\\$1'u+3n
- .nr )B \\n()Au+15n
- .\"
- .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
- .nr )C \\n()Bu+\\w'(in/out)'u+2n
- ..
- '\" # BS - start boxed text
- '\" # ^y = starting y location
- '\" # ^b = 1
- .de BS
- .br
- .mk ^y
- .nr ^b 1u
- .if n .nf
- .if n .ti 0
- .if n \l'\\n(.lu\(ul'
- .if n .fi
- ..
- '\" # BE - end boxed text (draw box now)
- .de BE
- .nf
- .ti 0
- .mk ^t
- .ie n \l'\\n(^lu\(ul'
- .el \{\
- .\" Draw four-sided box normally, but don't draw top of
- .\" box if the box started on an earlier page.
- .ie !\\n(^b-1 \{\
- \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
- .\}
- .el \}\
- \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
- .\}
- .\}
- .fi
- .br
- .nr ^b 0
- ..
- '\" # VS - start vertical sidebar
- '\" # ^Y = starting y location
- '\" # ^v = 1 (for troff; for nroff this doesn't matter)
- .de VS
- .mk ^Y
- .ie n 'mc \s12\(br\s0
- .el .nr ^v 1u
- ..
- '\" # VE - end of vertical sidebar
- .de VE
- .ie n 'mc
- .el \{\
- .ev 2
- .nf
- .ti 0
- .mk ^t
- \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
- .sp -1
- .fi
- .ev
- .\}
- .nr ^v 0
- ..
- '\" # Special macro to handle page bottom: finish off current
- '\" # box/sidebar if in box/sidebar mode, then invoked standard
- '\" # page bottom macro.
- .de ^B
- .ev 2
- 'ti 0
- 'nf
- .mk ^t
- .if \\n(^b \{\
- .\" Draw three-sided box if this is the box's first page,
- .\" draw two sides but no top otherwise.
- .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
- .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
- .\}
- .if \\n(^v \{\
- .nr ^x \\n(^tu+1v-\\n(^Yu
- \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
- .\}
- .bp
- 'fi
- .ev
- .if \\n(^b \{\
- .mk ^y
- .nr ^b 2
- .\}
- .if \\n(^v \{\
- .mk ^Y
- .\}
- ..
- '\" # DS - begin display
- .de DS
- .RS
- .nf
- .sp
- ..
- '\" # DE - end display
- .de DE
- .fi
- .RE
- .sp .5
- ..
- .HS string tcl
- .BS
- '\" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- string \- Manipulate strings
- .SH SYNOPSIS
- \fBstring \fIoption arg \fR?\fIarg ...?\fR
- .BE
-
- .SH DESCRIPTION
- .PP
- Performs one of several string operations, depending on \fIoption\fR.
- The legal \fIoption\fRs (which may be abbreviated) are:
- .TP
- \fBstring compare \fIstring1 string2\fR
- Perform a character-by-character comparison of strings \fIstring1\fR and
- \fIstring2\fR in the same way as the C \fBstrcmp\fR procedure. Return
- \-1, 0, or 1, depending on whether \fIstring1\fR is lexicographically
- less than, equal to, or greater than \fIstring2\fR.
- .TP
- \fBstring first \fIstring1 string2\fR
- Search \fIstring2\fR for a sequence of characters that exactly match
- the characters in \fIstring1\fR. If found, return the index of the
- first character in the first such match within \fIstring2\fR. If not
- found, return \-1.
- .TP
- \fBstring index \fIstring charIndex\fR
- Returns the \fIcharIndex\fR'th character of the \fIstring\fR
- argument. A \fIcharIndex\fR of 0 corresponds to the first
- character of the string.
- If \fIcharIndex\fR is less than 0 or greater than
- or equal to the length of the string then an empty string is
- returned.
- .TP
- \fBstring last \fIstring1 string2\fR
- Search \fIstring2\fR for a sequence of characters that exactly match
- the characters in \fIstring1\fR. If found, return the index of the
- first character in the last such match within \fIstring2\fR. If there
- is no match, then return \-1.
- .TP
- \fBstring length \fIstring\fR
- Returns a decimal string giving the number of characters in \fIstring\fR.
- .TP
- \fBstring match \fIpattern\fR \fIstring\fR
- See if \fIpattern\fR matches \fIstring\fR; return 1 if it does, 0
- if it doesn't. Matching is done in a fashion similar to that
- used by the C-shell. For the two strings to match, their contents
- must be identical except that the following special sequences
- may appear in \fIpattern\fR:
- .RS
- .IP \fB*\fR 10
- Matches any sequence of characters in \fIstring\fR,
- including a null string.
- .IP \fB?\fR 10
- Matches any single character in \fIstring\fR.
- .IP \fB[\fIchars\fB]\fR 10
- Matches any character in the set given by \fIchars\fR. If a sequence
- of the form
- \fIx\fB\-\fIy\fR appears in \fIchars\fR, then any character
- between \fIx\fR and \fIy\fR, inclusive, will match.
- .IP \fB\e\fIx\fR 10
- Matches the single character \fIx\fR. This provides a way of
- avoiding the special interpretation of the characters
- \fB*?[]\e\fR in \fIpattern\fR.
- .RE
- .TP
- \fBstring range \fIstring first last\fR
- Returns a range of consecutive characters from \fIstring\fR, starting
- with the character whose index is \fIfirst\fR and ending with the
- character whose index is \fIlast\fR. An index of 0 refers to the
- first character of the string. \fILast\fR may be \fBend\fR (or any
- abbreviation of it) to refer to the last character of the string.
- If \fIfirst\fR is less than zero then it is treated as if it were zero, and
- if \fIlast\fR is greater than or equal to the length of the string then
- it is treated as if it were \fBend\fR. If \fIfirst\fR is greater than
- \fIlast\fR then an empty string is returned.
- .TP
- \fBstring tolower \fIstring\fR
- Returns a value equal to \fIstring\fR except that all upper case
- letters have been converted to lower case.
- .TP
- \fBstring toupper \fIstring\fR
- Returns a value equal to \fIstring\fR except that all lower case
- letters have been converted to upper case.
- .TP
- \fBstring trim \fIstring\fR ?\fIchars\fR?
- Returns a value equal to \fIstring\fR except that any leading
- or trailing characters from the set given by \fIchars\fR are
- removed.
- If \fIchars\fR is not specified then white space is removed
- (spaces, tabs, newlines, and carriage returns).
- .TP
- \fBstring trimleft \fIstring\fR ?\fIchars\fR?
- Returns a value equal to \fIstring\fR except that any
- leading characters from the set given by \fIchars\fR are
- removed.
- If \fIchars\fR is not specified then white space is removed
- (spaces, tabs, newlines, and carriage returns).
- .TP
- \fBstring trimright \fIstring\fR ?\fIchars\fR?
- Returns a value equal to \fIstring\fR except that any
- trailing characters from the set given by \fIchars\fR are
- removed.
- If \fIchars\fR is not specified then white space is removed
- (spaces, tabs, newlines, and carriage returns).
-
- .SH KEYWORDS
- case conversion, compare, index, match, pattern, string
-